<?php
namespace app\controller;

use think\facade\Db;
use think\facade\Request;

class Api{
    public function apply(){
        if(Request::isPost()){

            $realname = trim(input('post.realname'));
            $mobile = trim(input('post.mobile'));
            if(empty($realname)){
                return_json(1,'请填写姓名');
            }
            if(empty($mobile)){
                return_json(1,'请填写手机号');
            }
            $insert = Db::table('active_user')->insert([
                'act_sch_id' => 1,
                'realname' => $realname,
                'mobile' => $mobile,
                'apply_time' => time(),
                'unique' => 'unique'
            ]);

            if(empty($insert)){
                return_json(1,'报名失败,请稍后再试');
            }
            return_json(0,'报名成功');
        }else{
            error_404();
        }
    }
}